﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Threading.Tasks;

namespace ContosoUniversity.Models
{
    /// <summary>
    /// 课程类
    /// </summary>
    public class Course
    {
        /// <summary>
        /// 不自增
        /// </summary>
        [DatabaseGenerated(DatabaseGeneratedOption.None)]
        [Display(Name = "Number")]
        public int CourseID { get; set; }

        [Display(Name = "Title")]
        [StringLength(50, MinimumLength = 3, ErrorMessage = "{0}3到50位")]
        public string Title { get; set; }

        [Display(Name = "Credits")]
        [Range(0, 5, ErrorMessage = "{0}0-5")]
        public int Credits { get; set; }

        /// <summary>
        /// 一个课程对应多个系，一个系里一个课程只有一个
        /// </summary>
        public int DepartmentID { get; set; }
        public Department Department { get; set; }

        public ICollection<Enrollment> Enrollments { get; set; }
        public ICollection<CourseAssignment> CourseAssignments { get; set; }
    }
}
